//底部菜单分类切换
$('#menu a').on('touchstart', function() {
	var thisClass = $(this).attr('class');
	if(thisClass.indexOf(' ') == -1) {
		$('body > section,#menu > a').removeClass('show');
		$('.' + thisClass).addClass('show');
	}
});

//首页*************
$(function() {
	//顶部banner图片
	var bannerTag = '<div class="mui-slider-item"><img src="img/BannerTest3.jpg" /></div><div class="mui-slider-item"><img src="img/BannerTest1.jpg" /></div><div class="mui-slider-item"><img src="img/BannerTest2.jpg" /></div><div class="mui-slider-item"><img src="img/BannerTest3.jpg" /></div><div class="mui-slider-item"><img src="img/BannerTest1.jpg" /></div>';
	$('#topBanner').append(bannerTag);
	//获得slider插件对象
	var gallery = mui('.mui-slider');
	gallery.slider({
		interval: 5000 //自动轮播周期，若为0则不自动播放，默认为0；
	});

	//课程分类切换
	$('#lectureType li').on('touchstart', function() {
		$(this).addClass('sl').siblings().removeClass('sl');
		var index = $(this).index();
		$('#lectureList > li').eq(index).addClass('show').siblings().removeClass('show');
	});

});

//课程培训***********
$(function() {
	//培训类别切换
	$('#trainClass > li').on('click', function() {
		$(this).addClass('sl').siblings().removeClass('sl');
		var index = $(this).index();
		$('#trainContent > li').eq(index).addClass('sl').siblings().removeClass('sl');
	});

	//选择导师地址方法
	function selectAddr() {
		$('#queryType').next().hide();
		//选择省市区
		var city_picker = new mui.PopPicker({
			layer: 3
		});
		city_picker.setData(init_city_picker);
		setTimeout(function() {
			city_picker.show(function(items) {
				$("#city_text").html((items[0] || {}).text + " " + (items[1] || {}).text + " " + (items[2] || {}).text);
				$("#city_text").attr('addrID', (items[0] || {}).value + "," + (items[1] || {}).value + "," + (items[2] || {}).value); //该ID为接收城市ID字段
			});
		}, 200);
	}
	//认证导师查询切换
	$('#queryType').change(function() {
		var type = $(this).val();
		var input = $('#queryType').next();
		var addr = $('#addr');
		switch(type) {
			case 'name':
				input.show().attr('placeholder', '请输入导师姓名');
				addr.hide();
				break;
			case 'IDCard':
				input.show().attr('placeholder', '请输入导师身份证号');
				addr.hide();
				break;
			case 'IDNo':
				input.show().attr('placeholder', '请输入导师证件编号');
				addr.hide();
				break;
			case 'area':
				addr.show().find('p').text('');
				selectAddr();
				break;
		}
	});
	$('#addr > p').on('click', function() {
		selectAddr();
	});

	//线上培训分类切换
	$('#onlineLesson a').on('click', function() {
		var thisClass = $(this).attr('class');
		if(thisClass.indexOf(' ') == -1) {
			$('.' + thisClass).addClass('show').siblings().removeClass('show');
		}
	});

});